package com.gqj.elec.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gqj.common.annotation.Log;
import com.gqj.common.core.controller.BaseController;
import com.gqj.common.core.domain.AjaxResult;
import com.gqj.common.enums.BusinessType;
import com.gqj.elec.domain.ElecWarning;
import com.gqj.elec.service.IElecWarningService;
import com.gqj.common.utils.poi.ExcelUtil;
import com.gqj.common.core.page.TableDataInfo;

/**
 * 物资报警Controller
 * 
 * @author lxq
 * @date 2023-09-02
 */
@RestController
@RequestMapping("/elec/elecWarning")
public class ElecWarningController extends BaseController
{
    @Autowired
    private IElecWarningService elecWarningService;

    /**
     * 查询物资报警列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarning:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElecWarning elecWarning)
    {
        startPage();
        List<ElecWarning> list = elecWarningService.selectElecWarningList(elecWarning);
        return getDataTable(list);
    }

    /**
     * 导出物资报警列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarning:export')")
    @Log(title = "物资报警", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElecWarning elecWarning)
    {
        List<ElecWarning> list = elecWarningService.selectElecWarningList(elecWarning);
        ExcelUtil<ElecWarning> util = new ExcelUtil<ElecWarning>(ElecWarning.class);
        util.exportExcel(response, list, "物资报警数据");
    }

    /**
     * 获取物资报警详细信息
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarning:query')")
    @GetMapping(value = "/{warningId}")
    public AjaxResult getInfo(@PathVariable("warningId") Long warningId)
    {
        return AjaxResult.success(elecWarningService.selectElecWarningByWarningId(warningId));
    }

    /**
     * 新增物资报警
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarning:add')")
    @Log(title = "物资报警", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElecWarning elecWarning)
    {
        return toAjax(elecWarningService.insertElecWarning(elecWarning));
    }

    /**
     * 修改物资报警
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarning:edit')")
    @Log(title = "物资报警", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElecWarning elecWarning)
    {
        return toAjax(elecWarningService.updateElecWarning(elecWarning));
    }

    /**
     * 删除物资报警
     */
    @PreAuthorize("@ss.hasPermi('elec:elecWarning:remove')")
    @Log(title = "物资报警", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warningIds}")
    public AjaxResult remove(@PathVariable Long[] warningIds)
    {
        return toAjax(elecWarningService.deleteElecWarningByWarningIds(warningIds));
    }
}
